<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-menu default-active='active' mode='horizontal' class='menu-unit'>
      <el-menu-item v-for='item in Container1' :index="'流程明细'===item.name?'active':'default'">
        <el-link @click="gotoMenu(item.url)" :type="'流程明细'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
      </el-menu-item>
    </el-menu>
    <table cellpadding="4" cellspacing="0" border="0" width="100%">
      <tr>
        <td class="containerBack">
          <el-form ref="form" :model="tree_steps" :rules="rules" label-width="100px" id="mvcfm">
            <el-button @click="gotoPage('/mes/produce/flow/ProductstatisticsPro?'+vueparams+'')" type='primary' size="mini">产品计件</el-button>
            <div class="form-unit">
              <span class="mvc-title-left"> 生产明细 </span>
            </div>
            <el-table :data="tree_steps">
              <el-table-column label="操作" align="center" width='100' type=''>
                <template slot-scope="scope">
                  <el-dropdown trigger="click">
                    <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item>
                        <el-link @click="popSettingPersonnel('&CMIDitem_work_id='+scope.row.item_work_id+'')">设置步骤人员</el-link>
                      </el-dropdown-item>
                      <el-dropdown-item>
                        <el-link @click="popStagePersonnel('&CMIDphase_work_id='+scope.row.phase_work_id+'')">设置阶段人员</el-link>
                      </el-dropdown-item>
                      <el-dropdown-item>
                        <el-link @click="gotoPage('/mes/produce/flow/AddRecordProcess?CMIDitem_work_id='+scope.row.item_work_id+''+vueparams+'')">添加记录</el-link>
                      </el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </template>
              </el-table-column>
              <el-table-column label="步骤" prop="">
                <template slot-scope="scope">
                  <span v-html="scope.row.__desc"></span>
                  <el-link @click="gotoPage('/mes/produce/flow/AddRecordProcess?CMIDitem_work_id='+scope.row.item_work_id+''+vueparams+'')" type='primary'>{{scope.row.workName}}</el-link>
                  <el-link @click="gotoPage('/mes/produce/flow/MachDetailed?CMSTEPWORKID='+scope.row.item_work_id+'&cpopup=reload'+vueparams+'')" type='primary'>{{emt.__desc}}</el-link>
                  <el-link @click="gotoPage('/mes/produce/flow/AssembleDetailed?CMSTEPWORKID='+scope.row.item_work_id+'&cpopup=reload'+vueparams+'')" type='primary'>{{emt.__desc}}</el-link>
                  <el-link @click="gotoPage('/mes/produce/flow/PurchaseDetailed?CMSTEPWORKID='+scope.row.item_work_id+'&cpopup=reload'+vueparams+'')" type='primary'>{{emt.__desc}}</el-link>
                </template>
              </el-table-column>
              <el-table-column label="人员" prop="contact_name">
              </el-table-column>
              <el-table-column label="时长" prop="duration">
              </el-table-column>
              <el-table-column label="开始时间" prop="start_time">
                <template slot-scope="scope">
                  {{getDateTimeString(scope.row,'start_time')}}
                </template>
              </el-table-column>
              <el-table-column label="结束时间" prop="end_time">
                <template slot-scope="scope">
                  {{getDateTimeString(scope.row,'end_time')}}
                </template>
              </el-table-column>
            </el-table>
          </el-form>
        </td>
      </tr>
    </table>
    <el-dialog :visible.sync="SettingPersonnelVisible" append-to-body>
      <SettingPersonnel v-if="SettingPersonnelVisible" ref="SettingPersonnel" :popparams="popparams"> </SettingPersonnel>
    </el-dialog>
    <el-dialog :visible.sync="StagePersonnelVisible" append-to-body>
      <StagePersonnel v-if="StagePersonnelVisible" ref="StagePersonnel" :popparams="popparams"> </StagePersonnel>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SettingPersonnel from "@/views/mes/produce/flow/SettingPersonnel";
  import StagePersonnel from "@/views/mes/produce/flow/StagePersonnel";
  export default {
    name: 'ProducePlanDetailed',
    components: {
      SettingPersonnel,
      StagePersonnel,
    },
    props: ['popparams'],
    data() {
      return {
        SettingPersonnelVisible: false,
        SettingPersonnelValue: null,
        SettingPersonnelDesc: null,
        StagePersonnelVisible: false,
        StagePersonnelValue: null,
        StagePersonnelDesc: null,
        vueparams: this.getVUEParams(""),
        tree_steps: [],
        loading: false,
        Container1: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "3FB71F06EF24449EA08DAA333F42CD9C",
        name: "流程图右菜单",
        selected: "流程明细"
      }, 'Container1', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/producePlanDetailed?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      popSettingPersonnel(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SettingPersonnelVisible = !this.SettingPersonnelVisible;
      },
      popStagePersonnel(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.StagePersonnelVisible = !this.StagePersonnelVisible;
      },
    },
  }
</script>
